package com.example.service;

import com.example.entity.Post;
import com.example.entity.RankLoading;
import com.example.mapper.PostMapper;
import com.example.mapper.RankLoadingMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
帖子业务处理
 */
@Service
public class RankLoadingService {

    @Resource
    private RankLoadingMapper rankLoadingMapper;

    public void add(RankLoading rankLoading) {
        rankLoadingMapper.insert(rankLoading);
    }

    public void deleteById(Integer id) {
        rankLoadingMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(RankLoading rankLoading) {
        rankLoadingMapper.updateById(rankLoading);
    }

    public RankLoading selectById(Integer id) {
        return rankLoadingMapper.selectById(id);
    }

    public List<RankLoading> selectAll(RankLoading rankLoading) {
        return rankLoadingMapper.selectAll(rankLoading);
    }

    public PageInfo<RankLoading> selectPage(RankLoading rankLoading, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<RankLoading> rankLoadingList = rankLoadingMapper.selectAll(rankLoading);
        return PageInfo.of(rankLoadingList);
    }
}
